package com.misty.singleton.client3;


import com.misty.singleton.Person;

/**
 * 双重检查锁的单例模式
 */
public class Singleton {
    private static Person instance;

    public Singleton() {
    }

    public static Person instance() {
        if (instance == null) {
            synchronized (Singleton.class) {
                if (instance == null) {
                    instance = new Person();
                }
            }
        }
        return instance;
    }
}
